package com.hpq.user.controller;

import com.hpq.common.domain.vo.request.IdReqVO;
import com.hpq.common.domain.vo.response.IdRespVO;
import com.hpq.common.domain.vo.response.ApiResult;
import com.hpq.common.utils.RequestHolder;
import com.hpq.user.domain.vo.request.user.UserEmojiReq;
import com.hpq.user.domain.vo.response.user.UserEmojiResp;
import com.hpq.user.service.UserEmojiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/capi/user/emoji")
@Api(tags = "用户表情包相关接口")
public class UserEmojiController {
    @Autowired
    private UserEmojiService userEmojiService;

    @GetMapping("/list")
    @ApiOperation("获取用户表情包列表")
    public ApiResult<List<UserEmojiResp>> getEmojiList() {
        return ApiResult.success(userEmojiService.list(RequestHolder.get().getUid()));
    }
    @PostMapping()
    @ApiOperation("新增表情")
    public ApiResult<IdRespVO> addEmoji(@Valid @RequestBody UserEmojiReq req) {
        return ApiResult.success(userEmojiService.insert(req, RequestHolder.get().getUid()));
    }
    @DeleteMapping()
    @ApiOperation("删除表情")
    public ApiResult<Void> deleteEmoji(@Valid @RequestBody IdReqVO reqVO) {
        userEmojiService.delete(reqVO.getId(), RequestHolder.get().getUid());
        return ApiResult.success();
    }
}
